import request from '/@/utils/request'

// 查询流程定义列表
export function listDefinition(query:any) {
  return request({
    url: '/flow/definition/list',
    method: 'get',
    params: query
  })
}

// 查询流程定义详细
export function getDefinition(id:string) {
  return request({
    url: '/flow/definition/' + id,
    method: 'get'
  })
}

// 获取流程定义xml字符串
export function saveXml(data:any) {
  return request({
    url: '/flow/definition/saveXml',
    method: 'post',
    data: data
  })
}

// 导出流程定义详细
export function exportDefinition(id:string) {
    return '/flow/definition/exportDefinition/' + id
}

// 获取流程定义xml字符串
export function xmlString(id:string) {
  return request({
    url: '/flow/definition/xmlString/' + id,
    method: 'get'
  })
}

// 新增流程定义
export function addDefinition(data:any) {
  return request({
    url: '/flow/definition/save',
    method: 'post',
    data: data
  })
}

// 修改流程定义
export function updateDefinition(data:any) {
  return request({
    url: '/flow/definition/update',
    method: 'post',
    data: data
  })
}

// 删除流程定义
export function delDefinition(id:string) {
  return request({
    url: '/flow/definition/delete/' + id,
    method: 'post'
  })
}

// 发布流程定义
export function publish(id:string) {
  return request({
    url: '/flow/definition/publish/' + id,
    method: 'get'
  })
}

// 取消发布流程定义
export function unPublish(id:string) {
  return request({
    url: '/flow/definition/unPublish/' + id,
    method: 'get'
  })
}

// 复制流程定义
export function copyDef(id:string) {
  return request({
    url: '/flow/definition/copyDef/' + id,
    method: 'get'
  })
}

// 查看流程图
export function chartDef(definitionId:string) {
  return request({
    url: '/flow/definition/chartDef/' + definitionId,
    method: 'get'
  })
}

// 查看流程图
export function flowImage(instanceId:string) {
  return request({
    url: '/flow/definition/flowChart/' + instanceId,
    method: 'get'
  })
}

// 激活流程
export function active(definitionId:string) {
  return request({
    url: '/flow/definition/active/' + definitionId,
    method: 'get'
  })
}

// 挂起流程
export function unActive(definitionId:string) {
  return request({
    url: '/flow/definition/unActive/' + definitionId,
    method: 'get'
  })
}

// 查询已发布表单定义列表
export function publishedList() {
  return request({
    url: '/warm-flow/published-form',
    method: 'get'
  })
}

export const uploadUrl = import.meta.env.VITE_API_URL + "/flow/definition/importDefinition"